<script type="text/javascript">
	$(function(){
		$("input:radio").click(function(){
			var value = 1;
			var id = $(this).val();
			$.post("questions/admin/questions/approve/" + id,{active:value}); 
		});
	})
</script>
<h1>คำถามชิงรางวัล</h1>
<?php echo $categories->pagination()?>
<table class="list">
	<tr>
		<th>แสดง</th>
		<th>ชุดคำถาม</th>
		<th>ผู้ตอบ</th>
		<th>สร้างโดย</th>
		<th width="90"><a class="btn" href="questions/admin/questions/form/" class="tiny">เพิ่มรายการ</a></th>
	</tr>
	<?php foreach($categories as $category): ?>
	<tr <?php echo cycle()?>>
		<td><input type="radio" name="active" value="<?php echo $category->id ?>" <?php echo ($category->active==1)?"checked='checked'":''?> /></td>
		<td><?php echo $category->name?></td>
		<td><a href="questions/admin/questions/answer_index/<?php echo $category->id ?>"><?php echo $category->answer_email->count()?> คน</a></td>
		<td><?php echo $category->user->fullname?></td>
		<td>
			<a class="btn" href="questions/admin/questions/form/<?php echo $category->id?>" >แก้ไข</a>
			<a class="btn" href="questions/admin/questions/delete/<?php echo $category->id?>" onclick="return confirm('คำถามทั้งหมดในชุดคำถามนี้จะถูกลบโดยอัตโนมัติ\nยืนยันการลบ')">ลบ</a>
		</td>
	</tr>
	<?php endforeach; ?>
</table>
<?php echo $categories->pagination()?>
	